package com.dfbz.demo01;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo02_StringBuilder常用方法 {


    public static void main(String[] args) {
        StringBuilder sb=new StringBuilder("hello world");

        // 把StringBuilder对象转换为String对象
        String str = sb.toString();
        System.out.println(str);
    }

    public static void reverse(String[] args) {
        StringBuilder sb = new StringBuilder("hello world");
        sb.reverse();
        System.out.println(sb);
    }


    public static void append(String[] args) {
        StringBuilder sb = new StringBuilder();
        sb.append("hello");
        System.out.println(sb);

        sb.append("world");
        System.out.println(sb);

        sb.append("abc");
        System.out.println(sb);
    }

    public static void 构造方法(String[] args) {

        StringBuilder sb1 = new StringBuilder();
        StringBuilder sb2 = new StringBuilder("123");

        System.out.println(sb1);
        System.out.println(sb2);
    }
}
